package com.elitesland.system.rest;

import com.elitesland.core.base.ApiResult;
import com.elitesland.system.service.SysNumberRuleDtlService;
import com.elitesland.system.vo.SysNumberRuleDtlVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <pre></pre>
 *
 * @author mir
 * @date 2020-10-11
 */
@RestController
@RequestMapping("/sys/numbering/ruledtls")
@Api(value = "发号器规则明细管理", tags = {"发号器API"})
public class SysNumberRuleDtlController {

    private SysNumberRuleDtlService sysNumberRuleDtlService;

    @Autowired
    public void setSysNumberRuleDtlService(SysNumberRuleDtlService sysNumberRuleDtlService) {
        this.sysNumberRuleDtlService = sysNumberRuleDtlService;
    }

    @PostMapping
    @ApiOperation("批量创建或更换规则明细")
    public ApiResult<Object> updateInBatch(@RequestBody List<SysNumberRuleDtlVO> details) {
        sysNumberRuleDtlService.updateInBatch(details);
        return ApiResult.ok();
    }

    @DeleteMapping
    @ApiOperation("根据规则明细ID列表，批量删除规则明细")
    public ApiResult<Object> removeInBatch(@RequestBody List<Long> ids) {
        sysNumberRuleDtlService.removeByIds(ids);
        return ApiResult.ok();
    }
}
